#include <iostream>
#include <fstream>
#include <cstring>


struct UserInfo
{
    int     id;
    char    user[64];
    char    passwd[64];
    char    phone[11];
    char    email[64];
};

using namespace std;

int main()
{
    fstream f;
    f.open("/var/lib/lijj/chat-online/text.dat", std::ios::out | std::ios::app | std::ios::binary);
    if(!f.is_open()) {
        cerr << "open file failed.\n";
        return 0;
    }

    UserInfo d;
    d.id = 1001;
    memcpy(d.user,      "lijj",   4);
    memcpy(d.passwd,    "lijj", 4);
    memcpy(d.phone,     "13051034157",  11);
    memcpy(d.email,     "lijiangjun931026@outlook.com",  28);
    
    f.seekg(0, std::ios::end);
    f.write((char*)&d, sizeof(d));

    f.close();
    
    return 0;
}